package com.lwc.cfdns.exception;

import com.lwc.cfdns.enums.ResultCode;
import lombok.Data;

/**
 * 授权异常
 *
 * @author luwc
 * @version 1.0.0
 * @throws
 * @time 2023/4/23 12:37:46
 */
@Data
public class AuthException extends RuntimeException {
    private int code;
    private String message;

    /**
     * Constructs a new exception with {@code null} as its detail message.
     * The cause is not initialized, and may subsequently be initialized by a
     * call to {@link #initCause}.
     */
    public AuthException() {
        super();
    }

    /**
     * Constructs a new exception with {@code null} as its detail message.
     * The cause is not initialized, and may subsequently be initialized by a
     * call to {@link #initCause}.
     */
    public AuthException(ResultCode resultCode) {
        super(resultCode.getMessage());
//        System.out.println(resultCode);
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
    }

    /**
     * 自定义message
     *
     * @param message
     * @return null
     * @throws
     * @version 1.0.0
     * @author luwc
     * @time 2023/4/29 7:05
     */
    public AuthException(String message) {
        super(message);
        this.code = ResultCode.ERROR.getCode();
        this.message = message;
    }
}
